<?php
class child{
	function LastRemaining_Solution($n, $m){
		if($n==1) return -1;
		$s = 0;
		for($i=1;$i<=$n;$i++){
			$s = ($s+$m)%$i;
			//echo $s;
		}
		return $s;
	}
}
$aa = new child;
$res = $aa->LastRemaining_Solution(10,6);
print_r($res);
?>